import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {catchError, throwError} from "rxjs";
import {environment} from '../../../environments/environment';
import {ApiReturnM} from '../../modules/ApiReturnM';
import {gettableMetaOUT} from '../../modules/gencode/GenCodeM';

//封装接口api
@Injectable({
  providedIn: 'root'
})
export class JimmerApiservice {

  static readonly baseurl: string = environment.JImmer_BASE_URL;
  static readonly gettableMetaUrl: string = "/login";
  static readonly refreshTokenUrl: string = "/refreshToken";
  static readonly permissionQueryallUrl: string = "/permission/queryall";

  constructor(private httpClient: HttpClient) {
  }

  //封装接口api
  gettableMeta(...tableName: string[]) {
    //使用泛型,数组
    return this.httpClient.post<ApiReturnM<gettableMetaOUT>>(
      JimmerApiservice.baseurl + JimmerApiservice.gettableMetaUrl,
      {tableName}
    ).pipe(
      catchError(err => throwError(err))
    )
  }


}
